<div class="primary">
   <div class="wrap">
      <?php include ROOT.'/home/view/view_bar.php'?>
      <div class="breadcrumb">
         <span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" class="crumb_item">
            <a itemprop="url" rel="up" class="crumb" href="/"><span itemprop="title">Trang chủ</span></a>
            <span class="arrow"> &gt; </span>
         </span>
         <span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" class="crumb_item">
            <a itemprop="url" rel="up" class="crumb" href="/phu-kien/"><span itemprop="title">Phụ kiện</span></a>
            <?=$curr_cat != '' ? '<span class="arrow"> &gt; </span>' : ''?>
         </span>
         <?
         if($curr_cat != '') {
         ?>
         <span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" class="crumb_item">
            <a itemprop="url" rel="up" class="crumb" href="/phu-kien-<?=$curr_cat['cat_alias']?>/"><span itemprop="title"><?=$curr_cat['cat_name']?></span></a>
         </span>
         <?
         }
         ?>
      </div>
      <div class="products_wrap">
         <div class="filter_wrap">
            <ul class="filter">
               <li class="first-li">Tìm theo <i class="icon-arrfilter"></i></li>
               <li>
                  <a href="javascript:;">Mức giá<span class="arrdown"></span></a>
                  <ul class="dropfilter">
                     <li>
                        <a<?=$filter_price == '' ? ' class="checked"' : ''?> href="<?=$current_url?>?<?=$tt_view.$current_filter_view?>">Tất cả</a>
                        <a<?=$filter_price == 'duoi-1-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=duoi-1-trieu<?=$tt_view.$current_filter_view?>">Dưới 1 triệu</a>
                        <a<?=$filter_price == 'duoi-2-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=duoi-2-trieu<?=$tt_view.$current_filter_view?>">Dưới 2 triệu</a>
                        <a<?=$filter_price == 'duoi-3-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=duoi-3-trieu<?=$tt_view.$current_filter_view?>">Dưới 3 triệu</a>
                        <a<?=$filter_price == 'duoi-5-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=duoi-5-trieu<?=$tt_view.$current_filter_view?>">Dưới 5 triệu</a>
                        <a<?=$filter_price == 'duoi-8-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=duoi-8-trieu<?=$tt_view.$current_filter_view?>">Dưới 8 triệu</a>
                        <a<?=$filter_price == 'duoi-10-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=duoi-10-trieu<?=$tt_view.$current_filter_view?>">Dưới 10 triệu</a>
                        <a<?=$filter_price == 'tren-10-trieu' ? ' class="checked"' : ''?> href="<?=$current_url?>?gia=tren-10-trieu<?=$tt_view.$current_filter_view?>">Trên 10 triệu</a>
                     </li>
                  </ul>
               </li>
               <li>
                  <a href="javascript:;">Loại phụ kiện<span class="arrdown"></span></a>
                  <ul class="dropfilter">
                  <?php
                  $list_cat1 = db_array('SELECT cat_name,cat_alias FROM categories WHERE cat_type = "accessories" LIMIT 0,15');
                  ?>
                     <li class="nofloat"><a<?=$_GET['catalias'] == '' ? ' class="checked"' : ''?> href="/phu-kien/">Tất cả</a></li>
                     <li>
                     <?php
                     foreach($list_cat1 as $cat) {
                        ?>
                        <a<?=($_GET['catalias'] == $cat['cat_alias']) ? ' class="checked"' : ''?> href="/phu-kien-<?=$cat['cat_alias']?>/"><?=$cat['cat_name']?></a>
                        <?
                     }
                     ?>
                     </li>
                  </ul>
               </li>
               <!--<li>
                  <a href="javascript:void(0)"><strong class="totalkm">72</strong>Khuyến mãi <span class="arrdown"></span></a>
                  <ul class="dropfilter">
                     <li>
                        <a href="<?=$current_url?>-dang-khuyen-mai" title="" class="hoverkm"><i class="icon-totalkm"></i>Xem 72 sản phẩm đang khuyến mãi</a>
                     </li>
                  </ul>
               </li>-->
            
               <li class="last-li"><a href="javascript:;">Sắp xếp hiển thị theo<span class="arrdown"></span></a>
                  <ul class="dropfilter">
                     <li>
                        <a<?=$filter_view == 'xem-nhieu-nhat' ? ' class="checked"' : ''?> href="<?=$current_url?>?<?=$current_filter_price.$tt_view?>sx=xem-nhieu-nhat">Xem nhiều nhất</a>
                        <a<?=$filter_view == 'gia-cao-den-thap' ? ' class="checked"' : ''?> href="<?=$current_url?>?<?=$current_filter_price.$tt_view?>sx=gia-cao-den-thap">Giá cao đến thấp</a>
                        <a<?=$filter_view == 'gia-thap-den-cao' ? ' class="checked"' : ''?> href="<?=$current_url?>?<?=$current_filter_price.$tt_view?>sx=gia-thap-den-cao">Giá thấp đến cao</a>
                     </li>
                  </ul>
               </li>
            </ul>
         </div><!-- filter_wrap -->
         <ul class="categorypromote">
            <li>
               <a href="#" target="_blank">iPhone 6 Plus</a>
            </li>
            <li>
               <a href="#" target="_blank">iPhone 6</a>
            </li>
            <li>
               <a href="#" target="_blank">Galaxy Note 4</a>
            </li>
            <li>
               <a href="#" target="_blank">Xperia Z3</a>
            </li>
            <li>
               <a href="#" target="_blank">Galaxy Note Edge</a>
            </li>
         </ul>
         <div class="anybanner">
            <a href="" target="_blank"><img src="http://cdn.tgdd.vn/qcao/09_10_2014_16_14_40_smartphone-hot-1.jpg" alt="" width="1170" height="120"/></a>
         </div>
         <div class="products_list">
         <?php
         $list_instock_status = array(0=>'Hết hàng',1=>'Còn hàng',2=>'Sắp về',3=>'Sắp ra mắt');
         foreach($list_products as $product) {
            ?>
            <div class="proitem">
               <?=$product['acc_promotion'] != '' ? '<span class="tagmotion">Khuyến mãi</span>' : ''?>
               <a href="<?=url_accessories_detail($product)?>">
                  <img src="<?=img_link($product['acc_image'],'small')?>" alt="<?=$product['acc_name']?>" />
                  <p class="goods"><?=$list_instock_status[$product['acc_instock_status']]?></p>
                  <h2 class="name"><?=$product['acc_name']?></h2>
                  <h4 class="price"><?=format_price($product['acc_price'])?></h4>
                  <?=$product['acc_promotion'] != '' ? '<p class="motion">Khuyến mãi lớn</p>' : ''?>
               </a>
            </div>
            <?
         }
         ?>
         </div>
         <?php
         if($total_products == 0) {
            echo '<h3>Không có sản phẩm nào được tìm thấy !</h3>';
         }elseif($total_products == 20) {
            ?>
            <button class="btnmorelist more_accessories" data-page="2" data-query="<?=base64_encode(json_encode($query_cat.$query_price.' '.$query_view))?>">Xem thêm sản phẩm</button>
            <script>
               $('.more_accessories').click(function(){
                  var query = $(this).attr('data-query');
                  var page = $(this).attr('data-page');
                  var data = {name:'more_accessories',query:query,page:page};
                  loadAjax(data,'json',{
                     success:function(res) {
                        if(res.status == 1) {
                           $('.products_list').append(res.html);
                           $('.imgloading').remove();
                           page++;
                           $('.more_accessories').attr('data-page',page);
                        }else if(res.status == 2) {
                           $('.products_list').append(res.html);
                           $('.imgloading').remove();
                           $('.more_accessories').remove();
                        }else {
                           $('.imgloading').remove();
                           $('.more_accessories').remove();
                        }
                     },
                     beforeSend:function() {
                        $('.products_list').append('<img style="display: inherit; margin: 5px auto;" class="imgloading" src="/themes/img/loadingcmt.GIF" />');
                     } 
                  });
               });
            </script>
            <?php
         }
         ?>
      </div><!-- products_wrap -->
   </div>
</div>